#include <bits/stdc++.h>
using namespace std;

int main()
{
    int a, b;
    cin >> a >> b; // a、b表示甲乙的酒量
    int a1 = a, b1 = b;
    int n;
    cin >> n;
    for (int _ = 1; _ <= n; _++)
    {
        vector<int> temp(4);
        cin >> temp[0] >> temp[1] >> temp[2] >> temp[3];
        int total = temp[0] + temp[2];

        bool fa = total == temp[1] ? true : false;
        bool fb = total == temp[3] ? true : false;

        if (fa == fb) continue;
        if (fa) a--;
        if (fb) b--;
        if (a < 0) {
            cout << "A" << endl << b1 - b << endl;
            break;
        }
        if (b < 0) {
            cout << "B" << endl << a1 - a << endl;
            break;
        }
    }
    return 0;
}